<template>
	<view class="content">
		<template v-if="list.length>0">
			<view class="info-block" v-for="item in list" :key="item.id">
				<view class="userInfo">
					<view class="user-left">
						<image :src="cloudStorage+item.faceUrl" mode=""></image>
						<view class="user">
							{{item.userName||'暂无'}}
						</view>
					</view>
					<view class="user-right">
						{{item.createTime||'暂无'}}
					</view>
				</view>
				<view class="gift">
					<view class="gift-top">
						{{item.typeName||'转账通知'}}
					</view>
					<view class="gift-bottom">
						￥{{item.voucher}}<text style="font-size: 20rpx;">券</text>
					</view>
				</view>
				<view class="order">
					<view class="order-left">
						订单编号
					</view>
					<view class="order-right">
						{{item.orderSn||'暂无'}}
					</view>
				</view>
				<view class="remark">
					<view class="remark-left">
						备注
					</view>
					<view class="remark-right">
						{{item.notes||'暂无'}}
					</view>
				</view>
			</view>
		</template>
		<view v-if="more==false&&list.length==0" style="width:100%;text-align: center;">暂无数据</view>
		<view v-else-if="more==false&&list.length>0" style="width:100%;text-align: center;">没有更多了</view>
	</view>
</template>

<script>
	import {
		getUserMessageBox
	} from '@/api/information.js'
	import {
		isMore
	} from '@/util/util.js'
	export default {
		data() {
			return {
				conf: {
					page: 1,
					limit: 10,
				},
				more: true,
				list: [],
			}
		},
		methods: {
			handleRefresh() {
				this.conf.page = 1;
				this.more = true
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.getList(true)
			},
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getUserMessageBox({
					page: this.conf.page,
					limit: this.conf.limit,
				}).then(res => {
					let list = res.list || [];
					if (refresh) {
						this.list = list;
					} else {
						this.list = [...this.list, ...list]
					}
					this.more = isMore(this.conf.page, this.conf.limit, res.count)
				})
			}
		},
		onPullDownRefresh() {
			this.handleRefresh();
		},
		onReachBottom() {
			if (this.more) {
				this.conf.page++;
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.getList();
			}
		},
		onLoad() {
			this.getList(true)
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		padding: 20rpx 30rpx 0;

		.info-block {
			background: #ffffff;
			padding: 30rpx;
			margin-bottom: 20rpx;

			.userInfo {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.user-left {
					display: flex;
					align-items: center;

					image {
						border-radius: 30rpx;
						width: 60rpx;
						height: 60rpx;
						margin-right: 10rpx;
					}

					.user {
						color: #1A1A1A;
						font-size: 32rpx;
					}
				}

				.user-right {
					color: #767676;
					font-size: 28rpx;
				}
			}

			.gift {
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				.gift-top {
					color: #767676;
					font-size: 28rpx;
					margin-top: 60rpx;
				}

				.gift-bottom {
					color: #1A1A1A;
					font-size: 40rpx;
					margin-top: 20rpx;
				}
			}

			.order {
				display: flex;
				margin-top: 60rpx;

				.order-left {
					width: 150rpx;
					color: #767676;
					font-size: 28rpx;
				}

				.order-right {
					color: #1A1A1A;
					font-size: 28rpx;
					width: 380rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
			}

			.remark {
				display: flex;
				margin-top: 20rpx;

				.remark-left {
					width: 150rpx;
					color: #767676;
					font-size: 28rpx;
				}

				.remark-right {
					color: #1A1A1A;
					font-size: 28rpx;
				}
			}
		}
	}
</style>